package com.xinjie.www.dao.ban;

import com.xinjie.www.dao.BaseDao;
import com.xinjie.www.po.Ban;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class BanDaoImpl implements BanDao {
    //获取封禁列表
    @Override
    public List<Ban> getBan(Connection connection) throws SQLException {
        PreparedStatement pstm = null;
        ResultSet rs = null;
        List<Ban> bans = new ArrayList<>();
        Object[] params = {};
        String sql = "select * from ban";
        rs = BaseDao.excute(connection, pstm, rs, sql, params);
        while (rs.next()) {
            Ban ban = new Ban();
            ban.setId(rs.getInt("id"));
            ban.setUserId(rs.getInt("user_id"));
            ban.setTiebaId(rs.getInt("tieba_id"));
            bans.add(ban);
        }
        BaseDao.closeResource(null, pstm, rs);
        return bans;
    }
}
